package ControlLayer;

import java.sql.Date;
import java.util.ArrayList;

import DBLayer.*;
import ModelLayer.*;



public class CtrLabour {
	
	DBLabour dbLabour;
	
	public CtrLabour()
	{
		dbLabour = new DBLabour();
	}

	
	
	
	public ArrayList<Labour> getAllLabour()
	{
		return dbLabour.getAllLabour();
	}
	
	
	
	public Labour findLabour(int labourId) 
	{
		return dbLabour.findLabour(labourId);
	}	
	
	
	public int deleteLabour(int labourId)
	{
		return dbLabour.deleteLabour(labourId);
	}
	
	
	public int updateLabour(int labourId, String name)
	{
		Labour labour = new Labour(labourId, name);
		return dbLabour.updateLabour(labour);
	}
	
	public void insertNewLabour(int labourId, String name)
    {    
     Labour labourObj = new Labour();
     
     labourObj.setLabourId(labourId);
     labourObj.setLabourName(name);
    

         try{
          DbConnection.startTransaction();
          
          DBLabour dbLabour = new DBLabour();
          dbLabour.insertLabour(labourObj);
          DbConnection.commitTransaction();
         }
         catch(Exception e)
         {
             DbConnection.rollbackTransaction();
         }
    }
	
}
